function Rename() {
  if($("input[type='checkbox']:checked").length != 1) {
    alert("Please select any one of the file/folder to rename!");
    return;
  }
  var oldfname = $("input[type='checkbox']:checked").val();
  var dir = ($("#currentdir").val() == "/") ? "/" : $("#currentdir").val() + "/";
  html = '<div id="dirtree" style="padding: 5px;"><label for="rtxt">Rename to: </label><input type="text" name="newname" id="rtxt" value="' + oldfname.substr(oldfname.lastIndexOf('/')+1) + '" size="20" /><br /></div>';
  $dialog = $('<div></div>')
  .html(html)
  .dialog({
    autoOpen: false,
    title: "Rename File/Folder",
    buttons: {
      "Close": function() {
        $(this).dialog('close');
      },
    
      "Rename": function() {
        $.ajax({
          type: "get",
          url: "modules/rename/rename.php",
          data: "t=" + new Date() + "&oldname=" + oldfname + "&newname=" + dir + $("#rtxt").val(),
          dataType: "text",
          success: function(data) {
            $($dialog).dialog('close');
            Browse($("#currentdir").val());
            alert(data);
          }
        });
      }
    },
    resizable: false,
    closeOnEscape: false,
    modal: true,
    close: function() {
      $(this).remove();
    }
  });
  $dialog.dialog('open');
}
